package io.github.jmjoy.grpc2http.proto.ring;

import static io.grpc.MethodDescriptor.generateFullMethodName;
import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall;
import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;
import static io.grpc.stub.ClientCalls.asyncServerStreamingCall;
import static io.grpc.stub.ClientCalls.asyncUnaryCall;
import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;
import static io.grpc.stub.ClientCalls.blockingUnaryCall;
import static io.grpc.stub.ClientCalls.futureUnaryCall;
import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall;
import static io.grpc.stub.ServerCalls.asyncClientStreamingCall;
import static io.grpc.stub.ServerCalls.asyncServerStreamingCall;
import static io.grpc.stub.ServerCalls.asyncUnaryCall;
import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;
import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;

/**
 */
@javax.annotation.Generated(
    value = "by gRPC proto compiler (version 1.10.0)",
    comments = "Source: ring.proto")
public final class RingHandlerGrpc {

  private RingHandlerGrpc() {}

  public static final String SERVICE_NAME = "ring.RingHandler";

  // Static method descriptors that strictly reflect the proto.
  @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901")
  @java.lang.Deprecated // Use {@link #getHandleMethod()} instead. 
  public static final io.grpc.MethodDescriptor<io.github.jmjoy.grpc2http.proto.ring.Ring.Request,
      io.github.jmjoy.grpc2http.proto.ring.Ring.Response> METHOD_HANDLE = getHandleMethodHelper();

  private static volatile io.grpc.MethodDescriptor<io.github.jmjoy.grpc2http.proto.ring.Ring.Request,
      io.github.jmjoy.grpc2http.proto.ring.Ring.Response> getHandleMethod;

  @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/1901")
  public static io.grpc.MethodDescriptor<io.github.jmjoy.grpc2http.proto.ring.Ring.Request,
      io.github.jmjoy.grpc2http.proto.ring.Ring.Response> getHandleMethod() {
    return getHandleMethodHelper();
  }

  private static io.grpc.MethodDescriptor<io.github.jmjoy.grpc2http.proto.ring.Ring.Request,
      io.github.jmjoy.grpc2http.proto.ring.Ring.Response> getHandleMethodHelper() {
    io.grpc.MethodDescriptor<io.github.jmjoy.grpc2http.proto.ring.Ring.Request, io.github.jmjoy.grpc2http.proto.ring.Ring.Response> getHandleMethod;
    if ((getHandleMethod = RingHandlerGrpc.getHandleMethod) == null) {
      synchronized (RingHandlerGrpc.class) {
        if ((getHandleMethod = RingHandlerGrpc.getHandleMethod) == null) {
          RingHandlerGrpc.getHandleMethod = getHandleMethod = 
              io.grpc.MethodDescriptor.<io.github.jmjoy.grpc2http.proto.ring.Ring.Request, io.github.jmjoy.grpc2http.proto.ring.Ring.Response>newBuilder()
              .setType(io.grpc.MethodDescriptor.MethodType.UNARY)
              .setFullMethodName(generateFullMethodName(
                  "ring.RingHandler", "Handle"))
              .setSampledToLocalTracing(true)
              .setRequestMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
                  io.github.jmjoy.grpc2http.proto.ring.Ring.Request.getDefaultInstance()))
              .setResponseMarshaller(io.grpc.protobuf.ProtoUtils.marshaller(
                  io.github.jmjoy.grpc2http.proto.ring.Ring.Response.getDefaultInstance()))
                  .setSchemaDescriptor(new RingHandlerMethodDescriptorSupplier("Handle"))
                  .build();
          }
        }
     }
     return getHandleMethod;
  }

  /**
   * Creates a new async stub that supports all call types for the service
   */
  public static RingHandlerStub newStub(io.grpc.Channel channel) {
    return new RingHandlerStub(channel);
  }

  /**
   * Creates a new blocking-style stub that supports unary and streaming output calls on the service
   */
  public static RingHandlerBlockingStub newBlockingStub(
      io.grpc.Channel channel) {
    return new RingHandlerBlockingStub(channel);
  }

  /**
   * Creates a new ListenableFuture-style stub that supports unary calls on the service
   */
  public static RingHandlerFutureStub newFutureStub(
      io.grpc.Channel channel) {
    return new RingHandlerFutureStub(channel);
  }

  /**
   */
  public static abstract class RingHandlerImplBase implements io.grpc.BindableService {

    /**
     */
    public void handle(io.github.jmjoy.grpc2http.proto.ring.Ring.Request request,
        io.grpc.stub.StreamObserver<io.github.jmjoy.grpc2http.proto.ring.Ring.Response> responseObserver) {
      asyncUnimplementedUnaryCall(getHandleMethodHelper(), responseObserver);
    }

    @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
      return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
          .addMethod(
            getHandleMethodHelper(),
            asyncUnaryCall(
              new MethodHandlers<
                io.github.jmjoy.grpc2http.proto.ring.Ring.Request,
                io.github.jmjoy.grpc2http.proto.ring.Ring.Response>(
                  this, METHODID_HANDLE)))
          .build();
    }
  }

  /**
   */
  public static final class RingHandlerStub extends io.grpc.stub.AbstractStub<RingHandlerStub> {
    private RingHandlerStub(io.grpc.Channel channel) {
      super(channel);
    }

    private RingHandlerStub(io.grpc.Channel channel,
        io.grpc.CallOptions callOptions) {
      super(channel, callOptions);
    }

    @java.lang.Override
    protected RingHandlerStub build(io.grpc.Channel channel,
        io.grpc.CallOptions callOptions) {
      return new RingHandlerStub(channel, callOptions);
    }

    /**
     */
    public void handle(io.github.jmjoy.grpc2http.proto.ring.Ring.Request request,
        io.grpc.stub.StreamObserver<io.github.jmjoy.grpc2http.proto.ring.Ring.Response> responseObserver) {
      asyncUnaryCall(
          getChannel().newCall(getHandleMethodHelper(), getCallOptions()), request, responseObserver);
    }
  }

  /**
   */
  public static final class RingHandlerBlockingStub extends io.grpc.stub.AbstractStub<RingHandlerBlockingStub> {
    private RingHandlerBlockingStub(io.grpc.Channel channel) {
      super(channel);
    }

    private RingHandlerBlockingStub(io.grpc.Channel channel,
        io.grpc.CallOptions callOptions) {
      super(channel, callOptions);
    }

    @java.lang.Override
    protected RingHandlerBlockingStub build(io.grpc.Channel channel,
        io.grpc.CallOptions callOptions) {
      return new RingHandlerBlockingStub(channel, callOptions);
    }

    /**
     */
    public io.github.jmjoy.grpc2http.proto.ring.Ring.Response handle(io.github.jmjoy.grpc2http.proto.ring.Ring.Request request) {
      return blockingUnaryCall(
          getChannel(), getHandleMethodHelper(), getCallOptions(), request);
    }
  }

  /**
   */
  public static final class RingHandlerFutureStub extends io.grpc.stub.AbstractStub<RingHandlerFutureStub> {
    private RingHandlerFutureStub(io.grpc.Channel channel) {
      super(channel);
    }

    private RingHandlerFutureStub(io.grpc.Channel channel,
        io.grpc.CallOptions callOptions) {
      super(channel, callOptions);
    }

    @java.lang.Override
    protected RingHandlerFutureStub build(io.grpc.Channel channel,
        io.grpc.CallOptions callOptions) {
      return new RingHandlerFutureStub(channel, callOptions);
    }

    /**
     */
    public com.google.common.util.concurrent.ListenableFuture<io.github.jmjoy.grpc2http.proto.ring.Ring.Response> handle(
        io.github.jmjoy.grpc2http.proto.ring.Ring.Request request) {
      return futureUnaryCall(
          getChannel().newCall(getHandleMethodHelper(), getCallOptions()), request);
    }
  }

  private static final int METHODID_HANDLE = 0;

  private static final class MethodHandlers<Req, Resp> implements
      io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
      io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
      io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
      io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
    private final RingHandlerImplBase serviceImpl;
    private final int methodId;

    MethodHandlers(RingHandlerImplBase serviceImpl, int methodId) {
      this.serviceImpl = serviceImpl;
      this.methodId = methodId;
    }

    @java.lang.Override
    @java.lang.SuppressWarnings("unchecked")
    public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) {
      switch (methodId) {
        case METHODID_HANDLE:
          serviceImpl.handle((io.github.jmjoy.grpc2http.proto.ring.Ring.Request) request,
              (io.grpc.stub.StreamObserver<io.github.jmjoy.grpc2http.proto.ring.Ring.Response>) responseObserver);
          break;
        default:
          throw new AssertionError();
      }
    }

    @java.lang.Override
    @java.lang.SuppressWarnings("unchecked")
    public io.grpc.stub.StreamObserver<Req> invoke(
        io.grpc.stub.StreamObserver<Resp> responseObserver) {
      switch (methodId) {
        default:
          throw new AssertionError();
      }
    }
  }

  private static abstract class RingHandlerBaseDescriptorSupplier
      implements io.grpc.protobuf.ProtoFileDescriptorSupplier, io.grpc.protobuf.ProtoServiceDescriptorSupplier {
    RingHandlerBaseDescriptorSupplier() {}

    @java.lang.Override
    public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() {
      return io.github.jmjoy.grpc2http.proto.ring.Ring.getDescriptor();
    }

    @java.lang.Override
    public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() {
      return getFileDescriptor().findServiceByName("RingHandler");
    }
  }

  private static final class RingHandlerFileDescriptorSupplier
      extends RingHandlerBaseDescriptorSupplier {
    RingHandlerFileDescriptorSupplier() {}
  }

  private static final class RingHandlerMethodDescriptorSupplier
      extends RingHandlerBaseDescriptorSupplier
      implements io.grpc.protobuf.ProtoMethodDescriptorSupplier {
    private final String methodName;

    RingHandlerMethodDescriptorSupplier(String methodName) {
      this.methodName = methodName;
    }

    @java.lang.Override
    public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() {
      return getServiceDescriptor().findMethodByName(methodName);
    }
  }

  private static volatile io.grpc.ServiceDescriptor serviceDescriptor;

  public static io.grpc.ServiceDescriptor getServiceDescriptor() {
    io.grpc.ServiceDescriptor result = serviceDescriptor;
    if (result == null) {
      synchronized (RingHandlerGrpc.class) {
        result = serviceDescriptor;
        if (result == null) {
          serviceDescriptor = result = io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME)
              .setSchemaDescriptor(new RingHandlerFileDescriptorSupplier())
              .addMethod(getHandleMethodHelper())
              .build();
        }
      }
    }
    return result;
  }
}
